package com.xu.packes.oco;

/**
 * @version v1.0
 * @类描述：
 * @项目名称：
 * @包名： com.xu.packes.oco
 * @类名称：OpenCloeMain
 * @创建人：YIHANG.XU
 * @创建时间：2021/3/123:01 下午
 * @修改人：YIHANG.XU
 * @修改时间：2021/3/123:01 下午
 * @修改备注：
 * @Copyright
 */
public class OpenCloeMain {
   //将具体的实现细节交给子类，通过增加子类来解决不能修改只能增加的开闭原则
    public static void main(String[] args) {
        Painting painting =new Painting();
        painting.ption(new Square());
        painting.ption(new Triangle());
        painting.ption(new Round());
    }
}
abstract class Ship {
    public int type;
    public abstract void row();
}

class Square extends Ship {
    Square() {
        super.type = 0;
    }

    @Override
    public void row() {
        System.out.println("方形");
    }
}

class Triangle extends Ship {
    Triangle() {
        super.type = 1;
    }
    @Override
    public void row() {
        System.out.println("圆形");
    }
}

class Round extends Ship {
    Round() {
        super.type = 2;
    }
    @Override
    public void row() {
        System.out.println("三角形");
    }
}
class Painting{
    public void ption(Ship ship){
       ship.row();
    }
}